package nl.tudelft.jpacman.npc.ghost;

import nl.tudelft.jpacman.board.BoardFactory;
import nl.tudelft.jpacman.board.Square;
import nl.tudelft.jpacman.level.LevelFactory;
import nl.tudelft.jpacman.level.MapParser;
import nl.tudelft.jpacman.npc.Ghost;

import java.util.List;

public final class GhostMapParser extends MapParser {
    private final GhostFactory ghostFactory;

    public GhostMapParser(LevelFactory levelFactory,
                          BoardFactory boardFactory,
                          GhostFactory ghostFactory) {
        super(levelFactory, boardFactory);
        this.ghostFactory = ghostFactory;
    }

    @Override
    protected void addSquare(Square[][] grid, List<Ghost> ghosts,
                             List<Square> startPositions, int x, int y, char c) {
        switch (c) {
            case 'C':
                Ghost clyde = ghostFactory.createClyde();
                grid[x][y] = makeGhostSquare(ghosts, clyde);
                break;
            default:
        }
    }

    private Square makeGhostSquare(List<Ghost> ghosts, Ghost ghost) {
        Square square = getBoardFactory().createGround();
        ghost.occupy(square);
        ghosts.add(ghost);
        return square;
    }

    private BoardFactory getBoardFactory() {
        return null;
    }
}
